<template>
  <div class="layout">
    <Layout :style="{minHeight: '100vh'}">
      <Sider ref="side1" hide-trigger collapsible :collapsed-width="78" v-model="isCollapsed" >
        <div class="layout-logo-left"></div>
        <div class="layout-nav">
          <Menu accordion theme="dark" width="auto" :open-names="openNames">
            <Submenu :name="item.name" v-for="item in menus" >
              <template slot="title">
                <Icon :type="item.icon" size="20"/>{{item.name}}
              </template>
                <MenuItem v-for="menuItem in item.child" :name="menuItem.name" :to="menuItem.link" >{{menuItem.name}}</MenuItem>
            </Submenu>
          </Menu>
        </div>
      </Sider>
      <Layout>
        <Header :style="{padding: 0}" class="layout-header-bar">
          <!--<Icon @click.native="collapsedSider" :class="rotateIcon" :style="{margin: '0 20px'}" type="md-menu" size="24"></Icon>-->
        </Header>
        <Content :style="{margin: '7px', background: '#fff', minHeight: '600px'}">
          <Card :style="{minHeight: '90vh'}">
            <router-view />
          </Card>
        </Content>
      </Layout>
    </Layout>
  </div>
</template>
<script>
  export default {
    data () {
      return {
        isCollapsed: false,
        openNames:['1'],
        active: 'home',
        menus: [
         {name:'配置管理',icon:'ios-cog-outline',
            child:[
              {name:'告警', link:'/alarm'},

            ]
          }
        ]
      }
    },
    computed: {
      rotateIcon () {
        return [
          'menu-icon',
          this.isCollapsed ? 'rotate-icon' : ''
        ];
      },
      menuitemClasses () {
        return [
          'menu-item',
          this.isCollapsed ? 'collapsed-menu' : ''
        ]
      }
    },
    methods: {
      // collapsedSider () {
      //   this.$refs.side1.toggleCollapse();
      // }
    }
  }
</script>
<style scoped>
  .layout{
    height: 100%;
    width: 100%;
    background: #f5f7f9;
    position: relative;
    border-radius: 4px;
    overflow: hidden;
  }
  .layout-header-bar{
    background: #fff;
    box-shadow: 0 1px 1px rgba(0,0,0,.1);
  }
  .layout-logo-left{
    width: 90%;
    height: 30px;
    background: #5b6270;
    border-radius: 3px;
    margin: 5px auto;
  }
  .menu-icon{
    transition: all .2s;
  }
  .rotate-icon{
    transform: rotate(-90deg);
  }
  .menu-item span{
    display: inline-block;
    overflow: hidden;
    width: 69px;
    text-overflow: ellipsis;
    white-space: nowrap;
    vertical-align: bottom;
    transition: width .2s ease .2s;
  }
  .menu-item i{
    transform: translateX(0px);
    transition: font-size .2s ease, transform .2s ease;
    vertical-align: middle;
    font-size: 16px;
  }
  .collapsed-menu span{
    width: 0px;
    transition: width .2s ease;
  }
  .collapsed-menu i{
    transform: translateX(5px);
    transition: font-size .2s ease .2s, transform .2s ease .2s;
    vertical-align: middle;
    font-size: 22px;
  }
</style>
